import { Component } from '@angular/core';
import { Payreport } from './payreport';

import { OnInit } from '@angular/core';
import { Router } from '@angular/router';

import { PayreportService } from './payreport.service';

@Component({
  selector: 'my-payreports',
  templateUrl: './payreport.component.html'
})

export class PayreportComponent implements OnInit {
  ngOnInit() {
    // let now = new Date().toDateString();
    // this.start_time = now;
    // this.end_time = this.start_time;
  }

  payreports: Payreport[];

  start_time:any;
  // = new Date().toDateString();
  end_time:any;
  // = new Date().toDateString();

  datePickerConfig = {
    "firstDayOfWeek": "su",
    "calendarsAmount": 1,
    "format": "YYYY-MM-DD",
    "monthFormat": "YYYY-MM-DD",
    "closeOnSelect": true,
    "closeOnSelectDelay": 100,
    "weekdayNames": {
      "su": "日",
      "mo": "一",
      "tu": "二",
      "we": "三",
      "th": "四",
      "fr": "五",
      "sa": "六"
    },
    "disableKeypress": true
  };

  constructor(
    private payreportService: PayreportService) {
  }

  getPayreports() {
    this.payreportService.searchPayreports(this.start_time, this.end_time).then(payreports => this.payreports = payreports);
  }

  search() {
    this.getPayreports();
  }
}
